Skip to content

feature : Add AVX2 base64 codec - #3684

Open
songgaoye wants to merge 5 commits into
apache:masterfrom
songgaoye:feature/base64-aklomp
Open

songgaoye wants to merge 5 commits into
apache:masterfrom
songgaoye:feature/base64-aklomp

Conversation

@songgaoye

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: resolve

Problem Summary:

Base64 encoding and decoding use scalar implementations on x86 even when AVX2 is available, limiting throughput for medium and large payloads.
What is changed and the side effects?
Changed:

  • Add an AVX2 Base64 codec derived from aklomp/base64, with BSD-2-Clause attribution.

  • Dispatch to AVX2 only on supported x86 CPUs.

  • Use measured thresholds to retain the scalar path for small inputs:

    • Encode: AVX2 from 32 bytes.
    • Decode: AVX2 from 256 bytes of Base64 text.
  • Add unit and fuzz coverage for binary round trips and invalid input.

  • Add reproducible scalar and AVX2 benchmark targets via BUILD_BASE64_BENCHMARKS.
    Side effects:

  • Performance effects:

    • On an Intel i7-10700, AVX2 improves encode throughput by roughly 5–12x and decode throughput by roughly 1.4–4.7x for sufficiently large inputs.
    • Small payloads continue to use the scalar path.
  • Breaking backward compatibility:


Check List:

@wwbmmm
wwbmmm requested a balanced review from Copilot October 28, 2026 05:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@wwbmmm wwbmmm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[replied by brpc-oncall robot] The AVX2 codec matches the scalar modp_b64 semantics for both valid and invalid inputs and the dispatch thresholds look reasonable, but the bundled BSD-2-Clause code is not recorded in the top-level LICENSE, the CPU feature check runs on every call, the first-block comment is inaccurate, and no test reaches the vectorized validation path.

Comment thread test/base64_unittest.cc Resolved
Comment thread CMakeLists.txt Resolved
@songgaoye
songgaoye requested a review from wwbmmm November 9, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants